﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AVCUMPlatform.DAL.Interface
{
    /// <summary>
    /// 数据访问基础类接口
    /// </summary>
    public partial interface IBasDAL<T>
    {
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        bool Add(T t);
        /// <summary>
        /// 增加返回自增id
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        int AddReturnAutoId(T t);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        bool Delete(List<int> ids);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        bool Update(T t);

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T Get(int id);

        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="count">总数</param>
        /// <param name="page">页码</param>
        /// <param name="per_page">分页大小</param>
        /// <returns></returns>
        List<T> GetList(out int count, int page = 1, int per_page = 20);


        /// <summary>
        /// 查询列表
        /// </summary>
        /// <returns></returns>
        List<T> GetAll();

        /// <summary>
        /// 获取数据条数
        /// </summary>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        int GetCount(string whereStr = null);

        /// <summary>
        /// 获取单条数据
        /// </summary>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        T GetModel(string whereStr = null);

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        List<T> GetModelList(string whereStr = null);

        /// <summary>
        /// 单表分页查询
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="param"></param>
        /// <param name="count"></param>
        /// <param name="where"></param>
        /// <param name="orderBy"></param>
        /// <returns></returns>
        List<T> SingleTablePageQuery(int pageIndex, int pageSize, out int count, string orderByFieldName, bool isDesc, string where, object param);

        /// <summary>
        /// 批量插入
        /// </summary>
        /// <param name="tList"></param>
        void RealBatchInsert(List<T> tList);
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="tList"></param>
        void RealBatchUpdate(List<T> tList);
    }
}
